package com.water.service;

import com.water.dao.TeamDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * @author wsj
 * @version 1.0
 * @description: TODO
 * @date 2022/1/8 17:21
 */
@Service
public class TeamService {
    //@Autowired //自动装配注解，默认按类型，若想按名字id，则要配合下面的@Qualifier("hhh")来使用，有setter方法也可以放
    //@Qualifier("hhh")
    private TeamDao teamDao;

    public void add(){
        teamDao.add();
    }

    public TeamService() {
        System.out.println("==========我是service默认构造================");
    }

    public TeamService(TeamDao teamDao) {
        this.teamDao = teamDao;
    }

    @Autowired(required = false)//false,报空指针异常，给个null；true，找不到，则程序报错中断。false还是常见的
    public void setTeamDao(TeamDao teamDao) {
        this.teamDao = teamDao;
    }

    public TeamDao getTeamDao() {
        return teamDao;
    }
}
